cdef extern from "math.h" nogil:
    float floor(float x)
    float exp (float x)
    float fabs(float x)
    int abs(int x)
    
    double ceil(double x)
    float ceil(float x)
    long double ceil(long double x)

cdef inline int round(float x) nogil: return <int> floor(x+0.5)

cdef inline int max(int x, int y) nogil: return (x>=y)*x+(x<y)*y
cdef inline float fmax(float x, float y) nogil: return (x>=y)*x+(x<y)*y

cdef inline int min(int x, int y) nogil: return (x<=y)*x+(x>y)*y
cdef inline float fmin(float x, float y) nogil: return (x<=y)*x+(x>y)*y

cdef inline int bound(int x, int xmin, int xmax) nogil: return min(max(x, xmin), xmax)
